/**
 * Copyright (C) 2013 SHANGHAI VOLKSWAGEN, All rights reserved.
 * License version 1.0, a copy of which has been included with this.
 *
 * @File name：com.market.remote.factory.RemoteOrderServiceFallbackFactory
 * @Create on：2024/2/27
 * @Author：liuchang
 */
package com.market.remote.factory;

import com.market.common.core.domain.Result;
import com.market.order.common.domain.TOrder;
import com.market.order.common.domain.TOrderDetail;
import com.market.remote.RemoteOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * <p>ClassName：RemoteOrderServiceFallbackFactory</p >
 * <p>Description：</p >
 * <p>Author：liuchang</p >
 * <p>Date：2024/2/27</p >
 */
@Component
public class RemoteOrderServiceFallbackFactory implements FallbackFactory<RemoteOrderService> {

    private static final Logger log= LoggerFactory.getLogger(RemoteOrderServiceFallbackFactory.class);

    @Override
    public RemoteOrderService create(Throwable throwable) {
        log.error("订单服务调用失败:{}"+throwable.getMessage());
        return new RemoteOrderService() {
            @Override
            public Result add(TOrder tOrder) {
                return Result.error("新增订单失败"+throwable.getMessage());
            }

            @Override
            public Result addDetail(TOrderDetail tOrderDetail) {
                return Result.error("新增订单明细失败"+throwable.getMessage());
            }

            @Override
            public Result getDetailInfo(Integer orderId) {
                return Result.error("订单明细查询失败"+throwable.getMessage());
            }

            @Override
            public Result updateOrderStatus(Integer orderId, Integer orderStatus) {
                return Result.error("订单状态修改失败"+throwable.getMessage());
            }

            @Override
            public Result sendMsg(String phone) {
                return Result.error("发送短信服务失败"+throwable.getMessage());
            }

            @Override
            public Result addOrder(TOrder tOrder) {
                return Result.error("订单新增失败"+throwable.getMessage());
            }
        };
    }
}
